﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using COM;
using BUS;

namespace EBOOK._USER
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            COM.DTO.User user = new COM.DTO.User();
            user.Username = txtUsername.Text;
            user.Password = COM.Encrypt.EncodePassword(txtPassword.Text);
            user.Role = UserHandler.getRole(COM.CONST.ROLE.SADMIN);
            user.Status = StatusHandler.getStatus(COM.CONST.USER.ACTIVE);
            user.Gender = COM.CONST.GENDER.MALE;
            user.FirstName = "Dang";
            user.LastName = "Dang";
            user.MiddleName = "Ho";
            bool isCreated = UserHandler.CreateNewUser(user);
            Response.Write("<script> alert('Create : " + isCreated + "---- Status : "+ user.Status.StatusName +"')</script>");

        }

        protected void btnAddress_Click(object sender, EventArgs e)
        {
            string hotelId = "HOTE_RIVERSIDE";
            string address = AddressHandler.getAbsoluteAddress(hotelId).ElementAt(0);
            Response.Write("<script> alert('Create : " + address + "')</script>");
        }
    }
}